/**
 * ExtensionInfo.java
 */
package tk.sunlatus.project.common;

import java.util.HashMap;
import java.util.Map;

/**
 * @author Sunlotus
 */
public class ExtensionInfo {
    private Map<String, String> extension = null;

    public Map<String, String> getExtension() {
        return extension;
    }

    public void setExtension(Map<String, String> extension) {
        this.extension = extension;
    }

    /**
     * 获取扩展属性
     * 
     * @param key
     *            扩展属性key
     * @return 扩展属性
     */
    public String getExtension(String key) {

        if (extension == null) {
            return null;
        }
        return extension.get(key);
    }

    /**
     * 添加扩展属性
     * 
     * @param key
     *            扩展属性key
     * @param value
     *            扩展属性
     */
    public void addExtension(String key, String value) {
        if (extension == null) {
            extension = new HashMap<String, String>();
        }
        extension.put(key, value);
    }

    /**
     * 添加多个扩展属性
     * 
     * @param extensions
     *            扩展信息集合
     */
    public void addAllExtension(Map<String, String> extensions) {
        if (extension == null) {
            extension = new HashMap<String, String>();
        }
        extension.putAll(extensions);
    }
}
